package cn.crawler.framework.base.model.enums;

/**
 * @author zl
 * @date 2020/8/4 11:00
 */
public enum BizExceptionEnum {
    //正确
    SUCCESS(1000,"success"),//默认
    SEND_CODE_SUCCESS(1001, "验证码发送成功"),
    REGISTER_SUCCESS(1002, "注册成功"),
    LOGIN_SUCCESS(1003, "登录成功"),
    UPDATE_SUCCESS(1004, "修改成功"),
    PWD_RESET_SUCCESS(1005, "密码重置成功"),
    ADD_SUCCESS(1006, "添加成功"),
    UPLOAD_SUCCESS(1007, "上传成功"),
    GET_SUCCESS(1008, "获取成功"),
    EXECUTION_SUCCEED(1009, "执行成功"),
    DEL_SUCCESS(1010, "删除成功"),
    VERIFIED_SUCCESS(1011, "验证成功"),

    //错误
    ERROR(-1000,"error"),//默认
    GET_CODES_FIRST(-1001, "请先获取验证码"),
    SEND_CODE_FAIL(-1002, "验证码发送失败"),
    DO_NOT_GET_CODES_FREQUENTLY(-1003, "请勿频繁获取短信验证码"),
    CODE_NOT_BE_NULL(-1004, "验证码不能为空"),
    ERROR_CODE(-1005, "验证码错误"),
    CODE_AND_EMAIL_INCONSISTENT(-1006, "验证码与邮箱不一致"),
    CODE_AND_PHONE_INCONSISTENT(-1007, "验证码与手机号不一致"),
    PHONE_EXIST(-1008, "手机号已存在"),
    PHONE_FORMAT_INCORRECT(-1009, "手机号码格式不正确"),
    PHONE_UNREGISTERED(-1010, "手机号码未注册"),
    PHONE_CAN_NOT_BE_NULL(-1011, "手机号不能为空"),
    PHONE_REGISTERED(-1012, "手机号码已注册"),
    EMAIL_EXIST(-1013, "邮箱已存在"),
    EMAIL_FORMAT_INCORRECT(-1014, "邮箱格式不正确"),
    EMAIL_UNREGISTERED(-1015, "邮箱未注册"),
    EMAIL_CAN_NOT_BE_NULL(-1016, "邮箱不能为空"),
    EMAIL_REGISTERED(-1017, "邮箱已注册"),
    INVITE_CODE_NOT_BE_NULL(-1018, "邀请码不能为空"),
    ERROR_INVITE_CODE(-1019, "邀请码有误"),
    REGISTER_FAILED(-1020, "注册失败"),
    LOGIN_EXCEPTION(-1021, "登录异常，请重新登录"),
    PWD_ERROR(-1022, "密码错误"),
    FAIL_EXCESSIVE(-1023, "错误次数过多请明日重试或重置密码"),
    ENTER_OLD_PWD(-1024, "请输入旧密码"),
    PWD_VERIFICATION_ERROR(-1025, "密码验证错误"),
    UPDATE_FAIL(-1026, "修改失败"),
    ERROR_NEW_PASSWORD(-1027, "新密码不能与原密码相同"),
    NICK_NAME_IRREGULAR(-1028, "昵称不符合规范"),
    NICK_NAME_EXISTED(-1029, "昵称已存在"),
    USER_DISABLED(-1030, "您的账号已被禁用"),
    //region 金额
    INSUFFICIENT_BALANCE(-10330, "账户余额不足"),
    INSUFFICIENT_FROZEN_BALANCE(-10331, "冻结余额不足"),
    MONEY_ERROR(-10332, "金额有误"),
    //endregion
    ENSURE_BEHAVIORAL_SAFETY(-1034, "请确保您的行为安全"),
    RECEIVER_NAME_CAN_NOT_BE_NULL(-1035, "收货人姓名不能为空"),
    RECEIVER_PHONE_CAN_NOT_BE_NULL(-1036, "收货人手机号不能为空"),
    SHIPPING_ADDRESS_CAN_NOT_BE_NULL(-1037, "收货地址不能为空"),
    ATTENDANT_PLEASE_LOGIN_PC(-1038, "客服请登录PC端"),
    NOT_ATTENDANT(-1039, "不是客服"),
    ATTENDANT_IS_OFFLINE(-1040, "客服已离线"),
    USER_LEAVED(-1041, "用户已离开"),
    NO_CORRESPONDING_USER(-1042, "没有对应的用户"),
    NOT_IN_THE_GROUP(-1043, "您已不在群里"),
    NOT_CHOOSE_GROUP(-1044, "未选择群组"),
    GROUP_MUTED(-1045, "群已禁言，无法发言"),
    USER_NOT_EXIST(-1046, "用户不存在"),
    ADD_FAIL(-1047, "添加失败"),
    REMOVE_FAIL_CAN_NOT_REMOVE_SELF(-1048, "移除失败，不能移除自己"),
    REMOVE_FAIL_NOT_OWNER_OR_GROUP_NOT_EXIST(-1049, "移除失败，你不是群主或群组不存在"),
    EMPTY_FILE(-1050, "空文件"),
    FILE_ILLEGAL(-1051, "文件不合法"),
    FILE_FORMAT_INCORRECT(-1052, "文件格式不正确"),
    PICTURE_FORMAT_INCORRECT(-1053, "图片格式不正确"),
    UPLOAD_FAIL(-1054, "上传失败"),
    NOT_SUBSCRIBED(-1055, "未订阅"),
    BANK_CARD_FORMAT_INCORRECT(-1056, "银行卡格式不正确"),
    PARAM_CAN_NOT_BE_NULL(-1057, "参数不得为空"),
    METHOD_CAN_NOT_IMPLEMENTED(-1058, "方法未实现"),
    ABNORMAL(-1059, "出现异常"),
    THE_ORDER_HAS_BEEN_OPERATED(-1060, "该单已操作"),
    RECHARGE_CHANNEL_CLOSED(-1061, "充值通道已关闭"),
    URL_FORMAT_INCORRECT(-1062, "URL格式不正确"),
    PICTURE_CAN_NOT_BE_NULL(-1063, "图片不能为空"),
    TYPE_ERROR(-1064, "类型错误"),
    NAME_CAN_NOT_BE_NULL(-1065, "名称不能为空"),
    GET_FAIL(-1066, "获取失败"),
    EXECUTION_FAILED(-1067, "执行失败"),
    URI_MAPPING_NOT_FOUND(-1068, "找不到URI映射"),
    CHOOSE_ONE_DAY_TO_CRAWLING(-1069, "选择1天进行爬取"),
    NO_ACCOUNT(-1070, "没有账号"),
    VERSION_NUMBER_ALREADY_EXISTS(-1071, "版本号已存在"),
    TASK_ALREADY_EXISTS(-1072, "任务已存在，请耐心等待结果"),
    NO_LONG_ACTIVITY_CHOOSE_DATE(-1073, "非长期活动请选择时间"),
    TITLE_EXISTS(-1074, "标题已存在"),
    NONE_AUTHORITY(-1075, "没有权限"),
    IP_EXISTS(-1076, "IP已存在"),
    SYS_PARAM_CANNOT_BE_DELETED(-1077, "系统参数不可删除"),
    USER_NAME_EXISTS(-1078, "用户名已存在!"),
    DEL_FAIL(-1079, "删除失败"),
    CANNOT_BE_DELETED(-1080, "不可删除"),
    NOT_ALLOW(-1081, "不支持"),
    SIGN_ERROR(-1082, "签名出错"),
    APP_ID_INCORRECT(-1083, "appid不正确"),
    TIMESTAMP_INCORRECT(-1084, "timestamp不正确"),
    NONCE_INCORRECT(-1085, "nonce不正确"),
    SIGN_SIGNATURE_INCORRECT(-1086, "sign签名不正确"),

    LOGIN_PWD_CAN_NOT_SAME_TO_TRANSACTION_PWD(-1087, "登录密码不能与交易密码相同"),
    NEW_PWD_CAN_NOT_SAME_TO_OLD_PWD(-1088, "新密码不能与旧密码相同"),
    RATE_ERROR_BET_FAILED(-1089, "利率错误，投资失败"),
    BET_FINISHED_STOP_BET(-1090, "招募完成，停止投资"),
    AMOUNT_TOO_LARGE_CANT_BET(-1096, "金额过大，不允许投资"),
    MATCH_STARTED_STOP_BET(-1097, "赛事已开始，停止投资"),
    SETTLE_TYPE_ERROR(-1091, "赛事未结束，不能结算"),
    USER_NAME_NOT_EXIST(-1092, "用户名不存在!"),
    USER_NAME_CAN_NOT_BE_NULL(-1093, "用户名不得为空!"),
    THE_BANK_CARD_IS_NOT_YOURS(-1094, "这个银行卡不是你的!"),
    BANK_CARD_NOT_EXIST(-1095, "银行卡不存在!"),

    ILLEGAL_OPERATION(-1999, "非法操作"),
    UN_LOGIN(-2000, "未登录"),
    ERROR_EMAIL(-2001, "邮箱错误"),
    BANK_CARD_ALREADY_EXIST(-2002, "银行卡已存在"),
    WITHDRAW_REJECT(-2003, "提现失败--充值注单总额需大于提现总额"),

    LOGIN_AFTER_ACCOUNT_SETTINGS_ARE_ENABLED(-2004, "账号设置启用后再登录"),

    HAS_UNFINISHED_RECHARGE(-2008, "尚未完成充值"),
    RETRY(-2012, "重新尝试"),
    CURRENCY_NOT_ALLOW_RECHARGE(-2018, "该币种不支持充值"),
    CURRENCY_NOT_ALLOW_WITHDRAW(-2019, "该币种不支持提现"),
    COLLECT_CARD_NOT_EXIST(-2025, "收款卡不存在"),
    DIGITAL_CURRENCY_NOW_ALLOW_RECHARGE_BY_BANK(-2030, "数字货币不能通过银行充值"),
    LEGAL_CURRENCY_NOW_ALLOW_RECHARGE_BY_DIGITAL_CHANNEL(-2031, "法币不能通过数字通道充值"),

    CROWN_LOGIN_EXCEPTION(-2040, "皇冠账号登录异常"),
    LESS_THAN_MIN_AMOUNT(-2050, "低于最低操作金额"),
    MORE_THAN_MAX_AMOUNT(-2051, "高于最高操作金额"),
    ERC20_ADDRESS_NOT_SET(-2060, "ERC20收款地址尚未配置"),
    PERMISSION_DENIED(-2070, "权限不足"),
    PAY_WAY_DISABLED(-2080, "渠道已禁用");
    private String code;
    private String msg;

    BizExceptionEnum(Integer code, String msg) {
        this.code = code.toString();
        this.msg = msg;
    }

    /**
     * @param code
     * @return msg
     */
    public static BizExceptionEnum getByCode(String code) {
        if (code != null) {
            for (BizExceptionEnum value : BizExceptionEnum.values()) {
                if (value.getCode().equals(code)) {
                    return value;
                }
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    @Override
    public String toString() {
        return code;
    }
}
